package org.example.controller;

import com.baomidou.mybatisplus.annotation.TableId;
import org.example.model.vo.OrdersVO;
import org.example.model.vo.ParticularsVO;
import org.example.service.IParticularsService;
import org.example.model.pojo.Particulars;
import cn.jiyun.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 【-Particulars】操作接口
 *
 * @author
 * @since 2024-12-23
 */
@RestController
@RequestMapping("/particulars")
@Api(tags = "操作接口")
public class ParticularsController {

    @Autowired
    public IParticularsService particularsService;


    /**
     * 接口：修改
     * @param particulars 要修改的数据
     * @return Result 响应给前端
     */
    @PutMapping("update")
    @ApiOperation("修改")
    public Result updateById(@RequestBody Particulars particulars) {
        particularsService.updateById(particulars);
        return Result.ok();
    }


    /**
      * 根据Id查询单个
     */
    @GetMapping("/findById/{orderId}")
    @ApiOperation("根据Id查询单个")
    public List<ParticularsVO> getById(@PathVariable Integer orderId)  {
        return particularsService.getByOrderId(orderId);
    }

    /**
     * 接口：查询所有
     */
    @PostMapping("/findAll")
    @ApiOperation("查询所有")
    public List<ParticularsVO> getList(@RequestBody ParticularsVO particularsVO) {
        return particularsService.findAll(particularsVO);
    }


    @PostMapping("/AddOrders")
    public Integer AddOrders(@RequestBody OrdersVO ordersVO) {
        ordersVO.setStatus("待支付,剩余时间");
        return particularsService.AddOrders(ordersVO);
    }

    @PostMapping("/findList")
    public List<Particulars> findList() {
        return particularsService.list();
    }



}
